package com.baizhi.action;

import java.util.List;

import com.baizhi.entity.Category;
import com.baizhi.entity.Page;
import com.baizhi.entity.Product;
import com.baizhi.service.BookService;
import com.baizhi.service.CategoryService;
import com.baizhi.service.impl.BookServiceImpl;
import com.baizhi.service.impl.CategoryServiceImpl;
import com.opensymphony.xwork2.ActionSupport;

public class BookAction extends ActionSupport{
	private BookService bs = new BookServiceImpl();
	private CategoryService cs = new CategoryServiceImpl();
	private List<Product> blist;
	private Product book;
	private Integer id = null;
	private Integer cid = null;
	private Page page = new Page();
	//分类所有信息
	private Category category;
	//排序的依据
	private Integer flag = 1;
	/*
	 * 查询热卖榜
	 */
	public String findHotBooks(){
		blist = bs.findHotBooks();
		return SUCCESS;
	}
	/*
	 * 编辑推荐书
	 */
	public String findRecommendBooks(){
		blist = bs.findRecommendBooks();
		return SUCCESS;
	}
	/*
	 * 最新上架图书
	 */
	public String findNewBooks(){
		blist = bs.findNewBooks();
		return SUCCESS;
	}
	/*
	 * 最新上架的热卖图书
	 */
	public String findNewHotBooks(){
		blist = bs.findNewHotBooks();
		return SUCCESS;
	}
	/*
	 * 查询单个图书
	 */
	public String findBookById(){
		book = bs.findBookById(id);
		return SUCCESS;
	}
	/*
	 * 根据分类ID查询商品
	 */
	public String findBooksByCid(){
		//根据分类查到商品
		blist = bs.findBoooksByCid(id,cid,page,flag);
		//根据分类ID  找到还有该分类ID的所有分类信息
		category = cs.findAllCategoryById(id);
		return SUCCESS;
	}
	
	public List<Product> getBlist() {
		return blist;
	}
	public void setBlist(List<Product> blist) {
		this.blist = blist;
	}
	public Product getBook() {
		return book;
	}
	public void setBook(Product book) {
		this.book = book;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getCid() {
		return cid;
	}
	public void setCid(Integer cid) {
		this.cid = cid;
	}
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}
	public Page getPage() {
		return page;
	}
	public void setPage(Page page) {
		this.page = page;
	}
	public Integer getFlag() {
		return flag;
	}
	public void setFlag(Integer flag) {
		this.flag = flag;
	}
}
